<%--
  Created by IntelliJ IDEA.
  User: 25786
  Date: 2020/7/7
  Time: 15:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>新增报案信息</title>
    <base href="${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${pageContext.request.contextPath}/"/>
    <link rel="icon" href="/static/images/favicon.ico">
    <link rel="stylesheet" href="/static/lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/css/layuimini.css" media="all">
    <link rel="stylesheet" href="/static/css/themes/default.css" media="all">
    <link rel="stylesheet" href="/static/lib/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/static/css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>新增报案信息</legend>
</fieldset>
<form class="layui-form" action="">
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">报案编号</label>
            <div class="layui-input-inline">
                <input type="text" name="caseReportId" id="caseReportId" lay-verify="caseReportId" autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">保单号</label>
            <div class="layui-input-inline">
                <input type="text" name="warrantyId" id="warrantyId" lay-verify="warrantyId" autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <%--<div class="layui-inline">
            <label class="layui-form-label">流程父id</label>
            <div class="layui-input-inline">
                <input type="text" name="taskpId" id="taskpId" lay-verify="taskpId" autocomplete="off"
                       class="layui-input" value="0" disabled>
            </div>
        </div>--%>
       <%-- <div class="layui-inline">
            <label class="layui-form-label">流程名称</label>
            <div class="layui-input-inline">
                <input type="text" name="taskName" id="taskName" lay-verify="taskName" autocomplete="off"
                       class="layui-input" value="报案" disabled>
            </div>
        </div>--%>
        <div class="layui-inline">
            <label class="layui-form-label">赔案号</label>
            <div class="layui-input-inline">
                <input type="text" name="claimMainId" id="claimMainId" lay-verify="claimMainId" autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">处理人</label>
            <div class="layui-input-inline">
                <input type="text" name="assignedName" id="assignedName" lay-verify="assignedName" autocomplete="off"
                       class="layui-input">
            </div>
        </div>

        <div class="layui-inline">
            <label class="layui-form-label">处理人id</label>
            <div class="layui-input-inline">
                <input type="text" name="assignedId" id="assignedId" lay-verify="assignedId" autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">报案人</label>
            <div class="layui-input-inline">
                <input type="text" name="reportPerson" id="reportPerson" lay-verify="reportPerson" autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">报案电话</label>
            <div class="layui-input-inline">
                <input type="text" name="reportPersonTel" id="reportPersonTel" lay-verify="reportPersonTel"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">出险司机</label>
            <div class="layui-input-inline">
                <input type="text" name="driver" id="driver" lay-verify="driver" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">司机电话</label>
            <div class="layui-input-inline">
                <input type="text" name="driverTel" id="driverTel" lay-verify="driverTel" autocomplete="off"
                       class="layui-input">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">车险地点所在省份/直辖市</label>
        <div class="layui-input-inline">
            <select name="province" lay-verify="province">
                <option value="">请选择省</option>
                <option value="浙江" selected="">浙江省</option>
                <option value="你的工号">江西省</option>
                <option value="你最喜欢的老师">福建省</option>
            </select>
        </div>
        <div class="layui-input-inline">
            <select name="city" lay-verify="city">
                <option value="">出现地点所在市</option>
                <option value="杭州">杭州</option>
                <option value="宁波" disabled="">宁波</option>
                <option value="温州">温州</option>
                <option value="温州">台州</option>
                <option value="温州">绍兴</option>
            </select>
        </div>
        <div class="layui-input-inline">
            <select name="county" lay-verify="county">
                <option value="">出现地点所在县/区</option>
                <option value="西湖区">西湖区</option>
                <option value="余杭区">余杭区</option>
                <option value="拱墅区">临安市</option>
            </select>
        </div>
    </div>

    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">详细地址</label>
        <div class="layui-input-block">
            <textarea placeholder="请输入内容" class="layui-textarea" lay-verify="fullAddress" name="fullAddress"
                      id="fullAddress"></textarea>
        </div>
    </div>

    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">出现经过</label>
        <div class="layui-input-block">
            <textarea placeholder="请输入内容" class="layui-textarea" lay-verify="dangerPass" name="dangerPass"
                      id="dangerPass"></textarea>
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">出现原因</label>
        <div class="layui-input-block">
            <textarea placeholder="请输入内容" class="layui-textarea" lay-verify="dangerCause" name="dangerCause"
                      id="dangerCause"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<script src="/static/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="/static/lib/jquery-3.4.1/jquery-3.4.1.min.js" charset="utf-8"></script>
<script>
    layui.use('form', function () {
        var form = layui.form
        var time = "";
        //自定义验证规则
       form.verify({
             dangerTime: function (value) {
                 if (value.length < 1) {
                     time=value;
                     return '请输入完整信息';
                 }
             },
             caseReportTime: function (value) {
                 if (value.length < 1 && value>=time) {
                     return '请输入有效信息';
                 }
             },
             province: function (value) {
                 if (value.length < 1) {
                     return '请输入完整信息';
                 }
             },
             city: function (value) {
                 if (value.length < 1) {
                     return '请输入完整信息';
                 }
             },
             county: function (value) {
                 if (value.length < 1) {
                     return '请输入完整信息';
                 }
             },
             fullAddress: function (value) {
                 if (value.length < 1) {
                     return '请输入完整信息';
                 }
             },
             dangerPass: function (value) {
                 if (value.length < 1) {
                     return '请输入完整信息';
                 }
             },
             dangerCause: function (value) {
                 if (value.length < 1) {
                     return '请输入完整信息';
                 }
             },
             driver: function (value) {
                 if (value.length < 1) {
                     return '请输入完整信息';
                 }
             },
             driverTel: function (value) {
                 if (value.length < 1) {
                     return '请输入完整信息';
                 }
             },
             reportPersonTel: function (value) {
                 if (value.length < 1) {
                     return '请输入完整信息';
                 }
             },
             caseReportId: function (value) {
                 if (value.length < 1) {
                     return '请输入完整信息';
                 }
             },
             warrantyId: function (value) {
                 if (value.length < 1) {
                     return '请输入完整信息';
                 }
             },
             taskpId: function (value) {
                 if (value.length < 1) {
                     return '请输入完整信息';
                 }
             },
             taskName: function (value) {
                 if (value.length < 1) {
                     return '请输入完整信息';
                 }
             },
             flowId: function (value) {
                 if (value.length < 1) {
                     return '请输入完整信息';
                 }
             },
             assignedId: function (value) {
                 if (value.length < 1) {
                     return '请输入完整信息';
                 }
             },
             assignedName: function (value) {
                 if (value.length < 1) {
                     return '请输入完整信息';
                 }
             },
             claimMainId: function (value) {
                 if (value.length < 1) {
                     return '请输入完整信息';
                 }
             }
         });
        //监听提交
        form.on('submit(demo1)', function (data) {
            //layer.alert(JSON.stringify(data.field)),
            var accident=data.field;
            $.ajax({
                url: "/warranty/getAll",
                method: "POST",
                contentType: "application/json;charset=utf-8",
                data: JSON.stringify(accident),
                dataType: "json",
                success: function (result) {
                   if(result.count==0){
                       layer.alert("修改失败，保单号不存在！");
                   }else if(result.count==1){
                       layer.alert("新增出险信息失败，输如的信息有误！");
                   }else if(result.count==2){
                       layer.alert("新增出险信息成功！");
                       layer.msg(data.msg, {icon:1,time:1_000}, function(){
                           var index = parent.layer.getFrameIndex(window.name);
                           parent.location.reload(); //刷新父页面
                           parent.layer.close(index);
                       });
                   }
                }
            });

            return false;
        });

       /* $.post('selectVoTest?Type=' + "selectGroup", function (data) {
            console.log(data);
            $("#Progress").append("<option value=" + 0 + ">" + "请选择" + "</option>");
            console.log(data);
            //Json 转换成json 对象
            var str = JSON.parse(data);
            console.log(str);
            $.each(str, function (i) {
                $("#Progress").append('<option value="' + str[i].id + '">' + str[i].name + '</option>');
            })
            form.render();//layui封装的遍历,每次绑定下拉框都需要加上
        })*/
    });
</script>
</body>
</html>
